<template>
	<view>
		<view class="center">
			<view class="back">
			</view>
			<view class="course_father">
				<view class="course">
					<view class="one">
						<view class="one_icons">
							<uni-icons type="calendar" color="#fff" size="60rpx"></uni-icons>
						</view>
						<view class="one_size">
							课程
						</view>
					</view>
					<view class="one">
						<view class="one_icons">
							<uni-icons type="calendar" color="#fff" size="60rpx"></uni-icons>
						</view>
						<view class="one_size">
							课程
						</view>
					</view>
					<view class="one">
						<view class="one_icons">
							<uni-icons type="calendar" color="#fff" size="60rpx"></uni-icons>
						</view>
						<view class="one_size">
							课程
						</view>
					</view>
				</view>
			</view>
			<view class="recommend_father">
				<view class="recommend">
					<view class="recommend_title">
						<view class=" left ">
							推荐课程
						</view>
						<view class=" right ">
							<view class="">
								全部{{recommendcounts}}个课程
							</view>
							<view class="">
								<uni-icons type="right" color="#fff" size="19rpx"></uni-icons>
							</view>
						</view>
					</view>
					<view class=" recommend_body ">
						<view class="recommend_two" v-for="(item,index) in recommendlist" :key="index">
							<view class="recommend_img">
								<image v-if="!item.photo==''" :src="imagesurl+item.photo"></image>
								<image v-else src="@/static/images/kecheng_01.jpg"></image>
							</view>
							<view class="recommend_name">
								{{item.name}}
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="recommend_father">
				<view class="recommend">
					<view class="recommend_title">
						<view class=" left ">
							推荐课程
						</view>
						<view class=" right ">
							<view class="">
								全部{{todaycounts}}个课程
							</view>
							<view class="">
								<uni-icons type="right" color="#fff" size="19rpx"></uni-icons>
							</view>
						</view>
					</view>

					<view class="today_body">
						<view class="recommend_two" v-for="(item,index) in todaylist" :key="index">
							<view class="recommend_img">
								<image v-if="!item.photo==''" :src="imagesurl+item.photo"></image>
								<image v-else src="@/static/images/kecheng_01.jpg"></image>
							</view>
							<view class="today_name">
								<view class="recommend_name">
									{{item.name}}
								</view>
								<view class=" weizhi ">
									位置
								</view>
								<view class=" date ">
									<view class="ss">
										<view class="week">
											星期
										</view>
										<view class=" time ">
											{{item.courseEndTime}} - {{item.courseStartTime}}
										</view>
									</view>
									<view class="yuyue">
										预约
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- center -->
		</view>
	</view>
</template>

<script>
	import {
		courseslist
	} from '@/api/api.js'
	export default {
		data() {
			return {
				imagesurl: 'http://apis.90000p.com/fkm/upload/',
				query: {
					type: 1,
					page: 1,
					psize: 4
				},
				recommendlist: [],
				recommendcounts: '',
				todaylist: [],
				todaycounts: '',
				pageCounts:'',
			};
		},
		onPullDownRefresh() {
			this.query.page = 1
			this.getcourseslist()
			this.todaycourseslist()
			uni.stopPullDownRefresh()
			this.$mess.success('刷新成功')
		},
		onReachBottom() {
				this.query.page++
				if(this.query.page > this.pageCounts ) return this.$mess.error('没有更多了')
				this.todaycourseslist()
		},
		onLoad() {
			this.getcourseslist()
			this.todaycourseslist()
		},
		methods: {
			async getcourseslist() {
				this.query.type = 1
				this.query.psize = 4
				let res = await courseslist(this.query)
				this.recommendlist = this.query.page ==1 ? res.data.list : [...this.recommendlist,...res.data.list]
				this.recommendcounts = res.data.counts
			},
			async todaycourseslist() {
				this.query.type = 0
				this.query.psize = 10
				let res = await courseslist(this.query)
				this.todaylist = this.query.page ==1 ? res.data.list : [...this.todaylist,...res.data.list]
				this.todaycounts = res.data.counts
				this.pageCounts = res.data.pageCounts


			}
		}
	}
</script>

<style lang="less">
	@import url('kechenglist.less');
</style>